<template>
  <div class='swiper-main'>
    <swiper :options="swiperOption">
      <swiper-slide
        v-for='(item,index) in swiperList'
        :key='index'
      >
        <img
          :src="item.imgUrl"
          alt="item.imgUrl"
        >
      </swiper-slide>
    </swiper>
    <div class="swiper-pagination"></div>
  </div>
</template>

<script>
import "swiper/dist/css/swiper.css";
import { swiper, swiperSlide } from "vue-awesome-swiper";
export default {
  name: "Swiper",
  props: {
    swiperList: Array,
    //用props接受 来自serve index.js 里面的数据
    //下面的wiperList: []就可以删掉了  //下面的wiperList的值已经复制到index.js里面了并赋值，这里只是声明swiperList
  },
  /*   props: {
    swiperList:[

    ],
  }, */

  data() {
    return {
      //swiperList: [
      //{
      //id: 1,
      //imgUrl: "./images/swiper1.jpeg",
      //},
      //{
      //id: 2,
      //imgUrl: "./images/swiper2.jpeg",
      //} /* 路径存疑，不懂 为什么不是../../public/images/swiper2.jpeg */,
      //{
      //id: 3,
      //imgUrl: "./images/swiper3.jpeg",
      //},
      //],
      swiperOption: {
        //swiper3
        autoplay: 3000,
        speed: 1000,
        pagination: {
          el: ".swiper-pagination",
        },
      },
    };
  },
  components: {
    swiper,
    swiperSlide,
  },
};
</script>

<style scoped>
.swiper-main {
  position: relative;
  /*   position: absolute; */
  width: 100%;
  /* margin-top: 0px; *原先是88 增加margin-top 下面删除height就能解决问题 */
  height: 4.3rem;
  /*top: 90px; /* 定位 */
}
.swiper-container {
  width: 100%;
  /*   height: 4.4rem; */
  /*top: 90px; /* 定位 */
}
.swiper-main img {
  width: 100%;
  /* height: 4.4rem;  */ /*  高度*/
}
.swiper-pagination {
  width: 100%;
  bottom: 5px;
}
/*穿透*/
::v-deep .swiper-pagination-bullet-active {
  background-color: #b0352f; /* 这里是小点的颜色*/
}
/*穿透*/
::v-deep .swiper-pagination-bullet {
  margin: 0 0.15rem; /*间隔 长度 */
}

::v-deep .swiper-slide img {
  width: 19.2rem;
  height: 4.2887rem;
}
</style>
